package com.hs.hlw.credit.system.business.dto;

import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * SubmissionFormDto
 * @author zhb
 * @date 2018/11/19
 */
public class SubmissionFormDto {
    @Data
    public static class Add {
        @NotBlank(message = "表单名称未填写")
        @Length(max = 20, message = "表单名称长度不能超过20个字符")
        private String name;
        @NotNull(message = "未选择数据源")
        private Integer dataSourceId;
        @NotNull(message = "未选择数据库表")
        private String tableId;
        @NotEmpty(message = "表单字段不能为空")
        private List<Field> fieldList;
        @Length(max = 500, message = "备注内容长度不能超过500个字符")
        private String remark;
    }

    @Data
    public static class Update {
        @NotNull(message = "未指定要修改的表单")
        private Integer id;
        @NotBlank(message = "表单名称未填写")
        @Length(max = 20, message = "表单名称长度不能超过20个字符")
        private String name;
        @NotNull(message = "未选择数据源")
        private Integer dataSourceId;
        @NotNull(message = "未选择数据库表")
        private String tableId;
        @NotEmpty(message = "表单字段不能为空")
        private List<Field> fieldList;
        @Length(max = 500, message = "备注内容长度不能超过500个字符")
        private String remark;

    }

    @Data
    public static class BatchUpdateStatus {
        @NotNull(message = "未指定状态")
        @Range(min = 0, max = 2, message = "指定状态有误")
        private Short status;
        @NotEmpty(message = "未指定表单")
        private List<SubmissionForm> formList;
    }

    @Data
    public static class SubmissionForm {
        private Integer id;
    }

    @Data
    public static class Field {
        private String fieldName;
        private String fieldCode;
        private String fieldDataType;
        private Integer fieldLength;
        private Short inputType;
        private Short displayStatus;
        private Short isReadOnly;
        private Short required;
        private String placeholder;
        private Integer sort;
        private Short isSearchCondition;
        private Short listDisplayStatus;
    }
}